All Functions Used So Far, Week 8

median

{stats}

Get median of a vector

geom_segment

{GGPLOT2}

Generates a line segment or curve

sum

{base}

Get sum of numeric values or a vector

ifelse

{base}

Return a or b depending on the value of test

sample

{base}

Takes a sample of the specified size

labs

{GGPLOT2}

Customise labels in GGPLOT2

theme_bw

{GGPLOT2}

A black and white ggplot theme

View

{base}

View a data frame

element_text

{GGPLOT2}

Customise text in GGPLOT2

mean

{base}

Get mean of a vector

geom_smooth

{GGPLOT2}

Generates a smoothed conditional means curve / line

theme_classic

{GGPLOT2}

A minimalistic theme with no gridlines

arrow

{GGPLOT2}

Draw an arrow in a ggplot graph

order

{base}

Get indexes that will sort a vector

which

{base}

return indexes of TRUE entries of a logical vector

dim

{base}

Get dimensions of a data frame

get_mode

{rstatix}

Compute the mode in a given vector.

class

{base}

Retrieve class of an R object

ggplot

{GGPLOT2}

Create a ggplot graph

stargazer

{stargazer}

Create a regression output table

prop.table

{base}

Transform frequency table into table of proportions

range

{base}

Return range of values

seq

{base}

Create a sequence

c

{base}

Combine values/vectors into a vector

geom_density

{GGPLOT2}

Generates a density plot

read.spss

{foreign}

Read a .sav file (SPSS data)

ggtitle

{GGPLOT2}

Generates a title for a ggplot graph

is.na

{base}

Check if a value is NA/elements of vector are NA

geom_bar

{GGPLOT2}

Generates a bar chart

geom_vline

{GGPLOT2}

Draws a vertical line

levels

{base}

Get levels of a factor

arrange

{dplyr}

Sort values of data frame according to a variable/combination of varaibles

expression

{base}

Used in plots to add symbols to axes

read_excel

{readxl}

Read an Excel file

rm

{base}

Remove objects

cor

{stats}

Calculate Correlation Matrix

cbind

{base}

Combine R objects by columns

with

{base}

evaluate expression in the context of a data frame

ls.str

{utils}

Similarly to ls, with a print() method that calls str() on each object

rnorm

{base}

Generate random numbers from a normal distribution

cor.test

{stats}

Test for Association/Correlation Between Paired Samples

summarise

{dplyr}

collapse the dataset to a summary statistic. Usually used with group_by()

barplot

{graphics}

Plot a simple bar plot

attach

{base}

Attach Set of R Objects to Search Path

ordered

{dplyr}

Create an ordered factor

prop.test

{stats}

Test of Equal or Given Proportions

geom_point

{GGPLOT2}

Generates a scatter plot

colnames

{base}

Retrieve column names of a data frame

max

{base}

Get maximum of a vector

bar

{base}

Used for annotations, such as “expression(paste(”-“,bar(y)))”

quantile

{stats}

Obtain empirical quantiles of a vector

scale_y_continuous

{GGPLOT2}

Customise continuous y axis

element_blank

{GGPLOT2}

This theme element draws nothing, and assigns no space

nrow

{base}

Get number of rows of a data frame

group_by

{dplyr}

Group tibble/data.frame by a factor variable. All further tidyverse operations are performed group-wise

lm

{base}

Fit a linear model

after_stat

{GGPLOT2}

Control aesthetic evaluation. On the module used for displying percent

library

{base}

Load an R package

setwd

{base}

Set Working Directory

as.factor

{base}

Coerce a vector to factor

head

{utils}

Show first 5 rows of a data frame

reorder

{stats}

Reorder Levels of Factor based on the values of a second variable, usually numeric.

cut

{base}

Convert Numeric to Factor

as.numeric

{base}

Coerce a vector to numeric

filter

{dplyr}

Filter out rows of a data frame according to logical vector

aes

{GGPLOT2}

Construct aesthetic mapping of a ggplot graph

par

{graphics}

Set parameters of the plotting device

as.data.frame

{base}

Functions to check if an object is a data frame, or coerce it if possible.

scale_colour_manual

{GGPLOT2}

Create your own discrete scale

sd

{stats}

Get standard deviation of a vector

round

{base}

Rounds numbers

pie

{graphics}

Creates a basic pie chart

hist

{graphics}

Plot a simple histogram

chisq.test

{stats}

Chi-Squared test (e.g. for cross-tabulations)

desc

{dplyr}

Arrange in descending order

geom_ribbon

{GGPLOT2}

Generates an area plot

ls

{base}

Return a vector of character strings giving the names of the objects in the specified environment

mutate

{dplyr}

Modify/create a column in a data frame

plot

{graphics}

Generic function from base R to produce a plot

table

{base}

Obtain frequency table of a variable/cross-tabulation of two variables

theme

{GGPLOT2}

Set theme for GGPLOT2

t.test

{stats}

Performs one and two sample t-tests on vectors of data.

summary

{base}

Obtain summary statistics or detailed regression output

names

{base}

Retrieve names of a list/vector

ylab

{GGPLOT2}

Label the y axis (ggplot)

lprop

{questionr}

Display row percentages of a two-way frequency table

predict

{stats}

Predict Probability

var

{stats}

Calculate variance

set.seed

{base}

Initialise a pseudorandom number generator.

str

{utils}

Get the structure of an R object

addmargins

{stats}

Puts Arbitrary Margins on Multidimensional Tables or Arrays

boxplot

{graphics}

Plot a simple box plot

coord_flip

{GGPLOT2}

Flip the x and y axes of a graph

print

{base}

Print object to the console

dnorm

{stats}

Density distribution for the normal distribution

read.csv

{utils}

Read a csv file to data frame. Specify stringsAsFactors = FALSE to keep all string columns as characters

ncol

{base}

Get number of columns of a data frame

install.packages

{base}

Install R package

subset

{base}

Return subsets of vectors, matrices or data frames which meet conditions.

ungroup

{dplyr}

Resolve grouping created with “group_by”

tabulate

{base}

Counts the number of times each integer occurs in an integer-only vector

factor

{base}

Create a factor

complete.cases

{stats}

Find Complete Cases

data.frame

{base}

Create a data.frame from vectors

min

{base}

Get minimum of a vector

runif

{stats}

Draws ranndom numbers from the uniform distribution

freq

{questionr}

Generate frequency tables

which.max

{base}

return index of the largest value in a vector

rbeta

{stats}

Beta Random Number Generating Function

sample_n

{dplyr}

Sample a number of observations from a data frame

geom_histogram

{GGPLOT2}

Generates a histogram

recode

{dplyr}

Recode a variable

scale_x_continuous

{GGPLOT2}

Customise continuous x axis

geom_hline

{GGPLOT2}

Add a horizontal line in GGPLOT2

unique

{base}

get unique elements

select

{dplyr}

Select columns from a tibble/data frame

confint

{stats}

Calculate confidence Intervals for Model Parameters

matrix

{base}

Creates a matrix from the given set of values.

slice

{dplyr}

Subset rows using their positions

grid.arrange

{gridExtra}

Places graphical objects into a rectangular grid

rbind

{base}

Combine R objects by rows

xlab

{GGPLOT2}

Label the x axis (ggplot)

tapply

{base}

Create statistical summaries by group based on the levels of one or several factors

The end!